package com.zzy.backend.consumer.utils;

import com.zzy.backend.pojo.User;
import com.zzy.backend.utils.JwtUtil;
import io.jsonwebtoken.Claims;

/**
 * @author molimark<br />
 * @date: 2023/3/14 19:38<br/>
 * @description: <br/>
 */


public class JwtAuthenticationUtil {
    public static Integer getUserId(String token){
        Integer userId = -1;
        try {
            Claims claims = JwtUtil.parseJWT(token);
            userId = Integer.parseInt(claims.getSubject());
        } catch (Exception e) {
            throw new RuntimeException(e);
        }

        return userId;
    }
}
